import createRouterMap from './create-route-map'
import createRoute from './util/route'
export default function createMatcher(routes){
  const {pathList,pathMap} = createRouterMap(routes)
  // console.log(pathList);
  // console.log(pathMap);
  function match(path){
    const record = pathMap[path]
    if(record){
      return createRoute(record,path)
    }
    return createRoute(null,path)
  }
  function addRoutes(routes){
    createRouterMap(routes,pathList,pathMap)
  }
  return {
    match,
    addRoutes
  }
}